Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
ff5517bc
Commit
ff5517bc
authored
12 years ago
by
Andreas Wundsam
Browse files
Options
Downloads
Patches
Plain Diff
openflowj/BasicFactory: inject factories to all newly created objects
parent
2e7883ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/openflow/protocol/factory/BasicFactory.java
+34
-18
34 additions, 18 deletions
...main/java/org/openflow/protocol/factory/BasicFactory.java
with
34 additions
and
18 deletions
src/main/java/org/openflow/protocol/factory/BasicFactory.java
+
34
−
18
View file @
ff5517bc
...
...
@@ -44,9 +44,20 @@ import org.openflow.protocol.vendor.OFVendorId;
*/
public
class
BasicFactory
implements
OFMessageFactory
,
OFActionFactory
,
OFStatisticsFactory
,
OFVendorDataFactory
{
/**
* create and return a new instance of a message for OFType t. Also injects
* factories for those message types that implement the *FactoryAware
* interfaces.
*
* @return a newly created instance that may be modified / used freely by
* the caller
*/
@Override
public
OFMessage
getMessage
(
OFType
t
)
{
return
t
.
newInstance
();
OFMessage
message
=
t
.
newInstance
();
injectFactories
(
message
);
return
message
;
}
@Override
...
...
@@ -92,18 +103,7 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
if
(
ofm
==
null
)
return
null
;
if
(
ofm
instanceof
OFActionFactoryAware
)
{
((
OFActionFactoryAware
)
ofm
).
setActionFactory
(
this
);
}
if
(
ofm
instanceof
OFMessageFactoryAware
)
{
((
OFMessageFactoryAware
)
ofm
).
setMessageFactory
(
this
);
}
if
(
ofm
instanceof
OFStatisticsFactoryAware
)
{
((
OFStatisticsFactoryAware
)
ofm
).
setStatisticsFactory
(
this
);
}
if
(
ofm
instanceof
OFVendorDataFactoryAware
)
{
((
OFVendorDataFactoryAware
)
ofm
).
setVendorDataFactory
(
this
);
}
injectFactories
(
ofm
);
ofm
.
readFrom
(
data
);
if
(
OFMessage
.
class
.
equals
(
ofm
.
getClass
()))
{
// advance the position for un-implemented messages
...
...
@@ -124,6 +124,21 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
}
}
private
void
injectFactories
(
OFMessage
ofm
)
{
if
(
ofm
instanceof
OFActionFactoryAware
)
{
((
OFActionFactoryAware
)
ofm
).
setActionFactory
(
this
);
}
if
(
ofm
instanceof
OFMessageFactoryAware
)
{
((
OFMessageFactoryAware
)
ofm
).
setMessageFactory
(
this
);
}
if
(
ofm
instanceof
OFStatisticsFactoryAware
)
{
((
OFStatisticsFactoryAware
)
ofm
).
setStatisticsFactory
(
this
);
}
if
(
ofm
instanceof
OFVendorDataFactoryAware
)
{
((
OFVendorDataFactoryAware
)
ofm
).
setVendorDataFactory
(
this
);
}
}
@Override
public
OFAction
getAction
(
OFActionType
t
)
{
return
t
.
newInstance
();
...
...
@@ -194,7 +209,7 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
* length of statistics
* @param limit
* number of statistics to grab; 0 == all
*
*
* @return list of statistics
*/
...
...
@@ -230,7 +245,7 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
* though we have a full message. Found when NOX sent
* agg_stats request with wrong agg statistics length (52
* instead of 56)
*
*
* just throw the rest away, or we will break framing
*/
data
.
readerIndex
(
start
+
length
);
...
...
@@ -247,7 +262,7 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
OFVendorDataType
vendorDataType
)
{
if
(
vendorDataType
==
null
)
return
null
;
return
vendorDataType
.
newInstance
();
}
...
...
@@ -259,6 +274,7 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
* @param length the length to the end of the enclosing message.
* @return an OFVendorData instance
*/
@Override
public
OFVendorData
parseVendorData
(
int
vendor
,
ChannelBuffer
data
,
int
length
)
{
OFVendorDataType
vendorDataType
=
null
;
...
...
@@ -268,13 +284,13 @@ public class BasicFactory implements OFMessageFactory, OFActionFactory,
vendorDataType
=
vendorId
.
parseVendorDataType
(
data
,
length
);
data
.
resetReaderIndex
();
}
OFVendorData
vendorData
=
getVendorData
(
vendorId
,
vendorDataType
);
if
(
vendorData
==
null
)
vendorData
=
new
OFByteArrayVendorData
();
vendorData
.
readFrom
(
data
,
length
);
return
vendorData
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment